package com.hyxt.DTO;

import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hyxt.api.TermianalLinkServer;
import com.hyxt.utils.IRedisMessageListener;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author shenp
 * @version v1.0
 * @Description 监听终端发送消息
 * @Date: Create in 15:46 2017/11/28
 * @Modifide By:
 **/
@Component
public class TermianalReMessageListener  extends IRedisMessageListener {
    @Reference(version = "1.0.0")
    TermianalLinkServer termianalLinkServer;
    @Override
    public void onMessage(String channel, String message) {
        System.out.println(channel);
        JSONObject jsonObject = JSON.parseObject(message, JSONObject.class);
        //唯一标识
        String sign = (String) jsonObject.get("sign");
        //原始数据
        String datas = (String) jsonObject.get("datas");
        byte[] bytes = datas.getBytes();
        termianalLinkServer.sendMessage(sign,bytes);
    }
}
